package com.roncoo.ysq.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.ysq.entity.HomeBottompage;
import com.roncoo.ysq.entity.HomePagecontrol;
import com.roncoo.ysq.service.IHomeBottompageService;
import com.roncoo.ysq.service.IHomePagecontrolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuanshuaiqiang
 * @since 2021-03-24
 */
@Api("底部文章")
@RestController
@RequestMapping("/home-bottompage")
public class HomeBottompageController {

    @Resource
    private IHomeBottompageService homeBottompageService;
    @Resource
    private IHomePagecontrolService homePagecontrolService;

    /**
     * 查询数据
     */
    @ApiOperation("查询所有数据，包括分页，模糊查询")
    @PostMapping("findAll")
    public IPage<HomeBottompage> findAll(Page page,HomeBottompage homeBottompage){
        IPage<HomeBottompage> all=homeBottompageService.findAll(page,homeBottompage);
        //System.out.println(all.getRecords()+"====");
        return all;
    }
    /**
     * 添加数据
     */
    @ApiOperation("根据传回的对象来进行添加")
    @PostMapping("addData")
    public Boolean adddata(HomeBottompage homeBottompage){
        return homeBottompageService.save(homeBottompage);
    }

    /**
     * 删除子菜单
     */
    @ApiOperation("根据传回的yId来删除子级菜单数据")
    @GetMapping("del")
    public Boolean del(Integer yId){
        return homeBottompageService.removeById(yId);
    }
    /**
     * 删除父子菜单
     */
    @ApiOperation("根据传回的yid删除父级和其下的子集菜单数据")
    @GetMapping("delByPid")
    public Boolean delByPid(Integer yId){
        return homeBottompageService.removeByPid(yId);
    }
    /**
     * 修改数据 子类
     */
    @ApiOperation("根据传回的对象里的id对子级菜单进行修改")
    @PostMapping("updData")
    public Boolean upddata(HomeBottompage homeBottompage){
        return homeBottompageService.updateById(homeBottompage);
    }
    /**
     * 修改数据 父子类
     */
    @ApiOperation("根据传回的对象里的id对父级和旗下的子级进行修改")
    @PostMapping("updDataByPid")
    public Boolean upddataByPid(HomeBottompage homeBottompage){
        Boolean bb=homeBottompageService.upddataByPid(homeBottompage);
        return bb;
    }
    /**
     * 根据yid查询文章
     */
    @ApiOperation("根据父级的id来查询文章表的相应的数据")
    @GetMapping("findPage")
    public HomePagecontrol findPage(Integer yId){
        HomePagecontrol homePagecontrol=homeBottompageService.findPage(yId);
        return homePagecontrol;
    }
    /**
     * 修改page
     */
    @ApiOperation("修改文章表的数据")
    @PostMapping("updPage")
    public Boolean updpage(HomePagecontrol homePagecontrol){
        return homePagecontrolService.updateById(homePagecontrol);
    }
    /**
     * before 查询数据
     */
    @ApiOperation("前端的查询正常状态的数据")
    @GetMapping("findByStatus")
    public List<HomeBottompage> findByStatus(){
        return homeBottompageService.findByStatus();
    }
}

